class Student:
    name = None
    age = None

    def __init__(self, name, age):
        self.name = name
        self.age = age

    # __str__魔术方法
    def __str__(self):  # 类似与Java的toString()
        return f"Student类的对象, name：{self.name}, age：{self.age}"

    # __lt__魔术方法    # 重载 <(>) 运算符
    def __lt__(self, other):
        return self.age < other.age

    # __le__魔术方法  # 重载 <=(>=) 运算符
    def __le__(self, other):
        return self.age <= other.age

    # __eq__魔术方法  # 类似于Java的equals()
    def __eq__(self, other):
        return self.age == other.age


stu1 = Student("周杰伦", 31)
stu2 = Student("林俊杰", 32)
print(stu1)
print(str(stu1))

print(stu1 < stu2)
print(stu1 > stu2)

print(stu1 <= stu2)

print(stu1.__eq__(stu2))
